/*
* @Author: Administrator
* @Date:   2018-01-08 14:29:45
* @Last Modified by:   Administrator
* @Last Modified time: 2018-01-13 21:30:31
*/
'use strict';

var _mm=require('util/mm.js');

var _user ={
	//登录

   login : function(userInfo, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/user/login.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //注册时判断用户名是否存在
     checkUsername : function(username, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/user/check_valid.do'),
            data    : {
                type    : 'username',
                str     : username
            },
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },

    //注册提交
    register :  function(userInfo, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/user/register.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },


	//登出
	logout		:function(resolve,reject){
		_mm.request({
			url 	:_mm.getServerUrl('/user/logout.do'),
			method	:'POST',
			success	:resolve,
			error	:reject
		});
	},
	//加载用户信息
	 checkLogin : function(resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/user/get_user_info.do'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },

    //获取用户密码提示问题
    getQuestion :function(username,resolve,reject){
         _mm.request({
            url     : _mm.getServerUrl('/user/forget_get_question.do'),
             method  : 'POST',
            data    : {
                username : username
            },
            success : resolve,
            error   : reject
        });
    },
  // 检查密码提示问题答案
    checkAnwer : function(userInfo,resolve,reject){
         _mm.request({
            url     : _mm.getServerUrl('/user/forget_check_answer.do'),
             method : 'POST',
            data    :userInfo,
            success : resolve,
            error   : reject
        });
    },

     // 重置密码
    resetPassword : function(userInfo, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/user/forget_reset_password.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
      // 获取用户信息
    getUserInfo : function(resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/user/get_information.do'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 登录状态下更新密码
    updatePassword : function(userInfo, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/user/reset_password.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
     // 更新个人信息
    updateUserInfo : function(userInfo, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/user/update_information.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
}
module.exports= _user;  //输出
  